<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Sets hook to execute when entering a function or method</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.uopz-restore.html">« uopz_restore</a></li>
      <li style="float: right;"><a href="function.uopz-set-mock.html">uopz_set_mock »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.uopz.html">Uopz 函数</a></li>
    <li>Sets hook to execute when entering a function or method</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.uopz-set-hook" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">uopz_set_hook</h1>
  <p class="verinfo">(PECL uopz 5, PECL uopz 6, PECL uopz 7)</p><p class="refpurpose"><span class="refname">uopz_set_hook</span> &mdash; <span class="dc-title">Sets hook to execute when entering a function or method</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.uopz-set-hook-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>uopz_set_hook</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$function</code></span>, <span class="methodparam"><span class="type"><a href="class.closure.html" class="type Closure">Closure</a></span> <code class="parameter">$hook</code></span>): <span class="type">bool</span></div>

  <div class="methodsynopsis dc-description"><span class="methodname"><strong>uopz_set_hook</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$class</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$function</code></span>, <span class="methodparam"><span class="type"><a href="class.closure.html" class="type Closure">Closure</a></span> <code class="parameter">$hook</code></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   Sets a hook to execute when entering a function or method.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.uopz-set-hook-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">class</code></dt>

    <dd>

     <p class="para">
      The name of the class.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">function</code></dt>

    <dd>

     <p class="para">
      The name of the function or method.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">hook</code></dt>

    <dd>

     <p class="para">
      A closure to execute when entering the function or method.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.uopz-set-hook-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>true</code></strong>， 或者在失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.uopz-set-hook-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="uopz-set-hook.example.basic">
   <p><strong>示例 #1 Basic <span class="function"><strong>uopz_set_hook()</strong></span> Usage</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">foo</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">uopz_set_hook</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">,&nbsp;function&nbsp;()&nbsp;{echo&nbsp;</span><span style="color: #DD0000">'bar'</span><span style="color: #007700">;});<br /></span><span style="color: #0000BB">foo</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程会输出：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
barfoo
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.uopz-set-hook-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="function.uopz-get-hook.html" class="function" rel="rdfs-seeAlso">uopz_get_hook()</a> - Gets previously set hook on function or method</span></li>
   <li class="member"><span class="function"><a href="function.uopz-unset-hook.html" class="function" rel="rdfs-seeAlso">uopz_unset_hook()</a> - Removes previously set hook on function or method</span></li>
  </ul>
 </div>


</div></div></div></body></html>